package com.lu.config;



import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import java.util.ArrayList;

@Configuration
public class SwaggerConfig {
    //    http://localhost:8080/swagger-ui/index.html新版路径
    @Bean//配置swagger的Docket bean实例
    public Docket docket(Environment environment){
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)//是否启用swagger是false 默认true
                .apiInfo(apiInfo())
                .select()
                //RequestHandlerSelectors配置要扫描接口的方式
                //any()扫描全部
                //none()不扫描
                //withClassAnnotation()扫描类上的注解,参数是一个注解的反射对象
                //withMethodAnnotation()扫描方法上的注解
                //basePackage()指定要扫描那个包
                .apis(RequestHandlerSelectors.basePackage("com.lu.controller"))
                //.paths(PathSelectors.ant("/hello/**"))//过滤什么路径
                .build()
                ;
    }


    //配置swagger的一些信息 作者信息
    public ApiInfo apiInfo(){
        Contact contact = new Contact("鲁家见","","482475181@qq.com");
        return new ApiInfo(
                "L的swagger的API文档",
                "Chats项目文档",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>());
    }

}